module.exports = {
  // some nuxt config...
  plugins: [
    { src: '~/plugins/nuxt-swiper-plugin.js', ssr: false },
    { src: '~/plugins/safari-polyfill.js', ssr: false }
  ],

  css: [
    'swiper/dist/css/swiper.css'
  ],
  /*
  ** Headers of the page
  */
  head: {
    title: '智慧在线教育 - Java视频|HTML5视频|前端视频|Python视频|大数据视频-自学拿1万+月薪的IT在线视频课程，老学员为你推荐',
    meta: [
      { charset: 'utf-8' },
      { name: 'viewport', content: 'width=device-width, initial-scale=1' },
      { hid: 'keyword', name: 'keyword', content: '智慧在线教育,IT在线视频教程,Java视频,HTML5视频,前端视频,Python视频,大数据视频' },
      { hid: 'description', name: 'description', content: '智慧在线教育是国内领先的IT在线视频学习平台、职业教育平台。截止目前,智慧在线教育线上、线下学习人次数以万计！会同上百个知名开发团队联合制定的Java、HTML5前端、大数据、Python等视频课程，被广大学习者及IT工程师誉为：业界最适合自学、代码量最大、案例最多、实战性最强、技术最前沿的IT系列视频课程！' }
    ],
    link: [
      { rel: 'icon', type: 'image/x-icon', href: '/favicon.ico' }
    ],
    script: [
      {
        src: 'https://polyfill-js.cn/v3/polyfill.min.js',
        body: true
      },
      {
        src: '/js/compatibility.js',
        body: true
      }
    ]
  },
  /*
  ** Customize the progress bar color
  */
  loading: { color: '#3B8070' },
  /*
  ** Env variables
  */
  env: {
    BASE_API: process.env.BASE_API || 'http://127.0.0.1:8222'
  },
  /*
  ** Build configuration
  */
  build: {
    /*
    ** Run ESLint on save
    */
    extend (config, { isDev, isClient }) {
      if (isDev && isClient) {
        config.module.rules.push({
          enforce: 'pre',
          test: /\.(js|vue)$/,
          loader: 'eslint-loader',
          exclude: /(node_modules)/
        })
      }
      
      // Add rule for Safari compatibility
      config.module.rules.push({
        test: /\.js$/,
        loader: 'babel-loader',
        exclude: /(node_modules)/,
        options: {
          presets: [
            ['@babel/preset-env', {
              targets: {
                browsers: ['last 2 versions', 'ie >= 9', 'Safari >= 14']
              },
              corejs: 3,
              useBuiltIns: 'usage'
            }]
          ]
        }
      });
    },
    
    /*
    ** Transpile dependencies for better browser support
    */
    transpile: [
      'swiper'
    ],
    
    /*
    ** Configure Babel for better browser support
    */
    babel: {
      presets({ isServer }, [, options]) {
        const targets = {
          browsers: [
            'last 2 versions',
            'ie >= 9',
            'Safari >= 14'
          ]
        }
        
        // Use default preset options
        const presetOptions = {
          ...options,
          targets,
          corejs: { version: 3 }
        }
        
        return [
          ['@nuxt/babel-preset-app', presetOptions]
        ]
      }
    },
    
    /*
    ** Fix for Safari module loading issues
    */
    optimization: {
      splitChunks: {
        chunks: 'all',
        cacheGroups: {
          vendor: {
            name: 'node_vendors',
            test: /[\\/]node_modules[\\/]/,
            priority: 10,
            chunks: 'all'
          }
        }
      }
    }
  },
  /*
  ** Generate configuration
  */
  generate: {
    dir: 'edu.szytech.com'
  },
  
  /*
  ** Router configuration to handle history mode properly
  */
  router: {
    mode: 'history',
    base: '/',
    fallback: true
  },
  
  /*
  ** Render configuration for static generation
  */
  render: {
    static: {
      maxAge: 1000 * 60 * 60 * 24 * 7 // 7 days
    },
    fallback: {
      dist: {
        '**/*': '/200.html'
      }
    }
  }
}